package cn.sh.yhk.service.basic.impl;

import cn.sh.yhk.mapper.basic.SCommonConfigMapper;
import cn.sh.yhk.model.basic.SCommonConfig;
import cn.sh.yhk.model.basic.SCommonConfigExample;
import cn.sh.yhk.service.basic.ConfigService;
import cn.sh.yhk.vo.BasicVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Auther: adminyhk
 * @Date: 2018/9/27 08:22
 * @Description:
 */
@Service
public class ConfigServiceImpl implements ConfigService {

    @Resource
    SCommonConfigMapper sCommonConfigMapper;

    @Override
    public BasicVo getAllConfig() {
        return BasicVo.success(sCommonConfigMapper.selectByExample(new SCommonConfigExample()));
    }

    @Override
    public BasicVo getConfigById(Long id) {
        SCommonConfigExample ex = new SCommonConfigExample();
        ex.createCriteria().andIdEqualTo(id.intValue());
        SCommonConfig config = sCommonConfigMapper.selectConfigByExample(ex);
        if (config != null) {
            return BasicVo.success(config);
        } else {
            return BasicVo.fail("请求失败");
        }
    }
}
